import { tokenRequest } from "../utils/request";

export function getClocks() {
    return tokenRequest({
        url: 'clock/clocks',
        method: 'GET',
    })
}

export function createClockItem(name, tags, target) {
    return tokenRequest({
        url: 'clock/clocks-item',
        method: 'POST',
        param: { name, tags, target },
        header: {
            'Content-type': 'application/x-www-form-urlencoded'
        }
    })
}

export function deleteClockItem(id) {
    return tokenRequest({
        url: 'clock/clocks-item',
        method: 'DELETE',
        param: { id, type: 'one' },
        header: {
            'Content-type': 'application/x-www-form-urlencoded'
        }
    })
}

export function deleteManyClockItem(id) {
    return tokenRequest({
        url: 'clock/clocks-item',
        method: 'DELETE',
        param: { id, type: 'multiple' },
        header: {
            'Content-type': 'application/x-www-form-urlencoded'
        }
    })
}

export function changeClockState(id, state) {
    return tokenRequest({
        url: 'clock/clocks-item/playing',
        method: 'PUT',
        param: { id, state },
        header: {
            'Content-type': 'application/x-www-form-urlencoded'
        }
    })
}